package com.mini.demos.webgame.codec;

import org.apache.mina.core.buffer.IoBuffer;

import com.mini.demos.webgame.msg.AbstractGameMsg;
import com.mini.demos.webgame.msg.RegMsgResp;
import com.mini.demos.webgame.util.Constants;
import com.mini.framework.communicate.mina.protocol.Msg;

public class RegRespEncoder extends AbstractEncoder {

	@Override
	public void encodeBody(AbstractGameMsg msg, IoBuffer buffer) {
		RegMsgResp regMsgResp = (RegMsgResp)msg;
		buffer.putInt(regMsgResp.getCode());
		try{
			buffer.putString(regMsgResp.getMsg(), Constants.charset.newEncoder());
		}catch(Exception e){
			e.printStackTrace();
		}

	}

	@Override
	public Class<? extends Msg> getMsgType() {
		return RegMsgResp.class;
	}

}
